package sample;

import javafx.scene.canvas.Canvas;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.scene.control.Label;
import javafx.scene.paint.Color;
import javafx.scene.text.*;

import java.io.File;


public class GetPreview extends BaseTool {
    String choosePath;
    double proportion;



    public String getChoosePath() {
        return choosePath;
    }

    public void setChoosePath(String choosePath) {
        this.choosePath = choosePath;
    }

    public double getProportion() {
        return proportion;
    }

    public void setProportion(double proportion) {
        this.proportion = proportion;
    }

    /* 顶部状态栏资源*/
    HBox topHbox = new HBox();
    HBox topLeftHbox = new HBox();
    HBox topCenterHbox = new HBox();
    HBox topRightHbox = new HBox();
    HBox topHBox = new HBox();

    ImageView imageView_4g = new ImageView();
    ImageView imageView_sign = new ImageView();
    ImageView dialerMainBG = new ImageView();
    ImageView imageView_time = new ImageView();
    ImageView imageView_wifi = new ImageView();
    ImageView imageView_battery = new ImageView();

    Pane topPane = new Pane();
    Pane topLeftPane = new Pane();
    Pane topCenterPane = new Pane();
    Pane topRightPane = new Pane();

    String FileName = null;

    public Pane getDialerPane(String choosePath, int proportion) throws Exception {

        //   System.out.println("用户选择的路径是" + choosePath);
        String temPath = choosePath.substring(choosePath.lastIndexOf("\\") + 1);
        FileName = temPath;
        //  System.out.println("当前的主题为" + " " + FileName);

        GridPane temp_dialerPane = new GridPane();


        /* 提示栏资源*/
        HBox dialer_tipHbox = new HBox();
        ImageView imageView_tip = new ImageView();
        Pane dialer_tipPane = new Pane();

        /* 键盘资源*/
        HBox dialer_keyHbox = new HBox();
        Pane dialer_keyPane = new Pane();
        ImageView imageView_key = new ImageView();

        /* 底部资源*/
        ImageView imageView_buttomPeople = new ImageView();
        ImageView imageView_buttomPhone = new ImageView();
        ImageView imageView_buttomBack = new ImageView();
        ImageView imageView_buttomBackGroud = new ImageView();

        StackPane buttomStackPane = new StackPane();
        Pane dialer_buttomPane = new Pane();
        HBox dialer_buttomHbox = new HBox();

        //拨号盘的主背景
        String dialerMainBGPath = choosePath + File.separator + "vivo" + File.separator + "vigour_window_bg_dark.9.png";
        dialerMainBG = getCanvasImage(dialerMainBGPath, 1080, 1920, 1080, 1920, proportion, 1, 0);

      /*  String dialerMainBGPath = choosePath + File.separator + "preview" + File.separator + "preview_contact_0.jpg";
        ImageView dialerMainBG=getImageView(dialerMainBGPath,1080,1920,3);*/
        // Canvas dialerMainBGCanvas = getNineCanvas(dialerMainBGPath, 1082, 1922, 1082, 1922, proportion, 1);

        //拨号盘的状态栏
        topPane.getChildren().setAll(getTopPane(choosePath, proportion, 0));

        // 拨号盘的提示
        String dialerTipPath = choosePath + File.separator + "com.android.dialer" + File.separator + "bbk_smart_dialer_tips.png";
        imageView_tip = getImageView(dialerTipPath, 1080, 1920, proportion);
        imageView_tip.setX(0);
        imageView_tip.setY(0);
        dialer_tipPane.getChildren().setAll(imageView_tip);
        dialer_tipHbox.getChildren().setAll(dialer_tipPane);

        //拨号盘的键盘
        String dialerKeyPath = choosePath + File.separator + "com.android.dialer" + File.separator + "bbk_dialpad_background.png";
        imageView_key = getImageView(dialerKeyPath, 1080, 612, proportion);
        imageView_key.setX(0);
        imageView_key.setY(1153 / proportion);
        dialer_keyPane.getChildren().setAll(imageView_key);
        dialer_keyHbox.getChildren().setAll(dialer_keyPane);

        // 拨号盘的底部
        String dialerButtomPeople = choosePath + File.separator + "com.android.dialer" + File.separator + "bbk_dialer_to_contact.png";
        imageView_buttomPeople = getImageView(dialerButtomPeople, 128, 128, proportion);
        imageView_buttomPeople.setX(112 / proportion);
        imageView_buttomPeople.setY(1770 / proportion);

        String dialerButtomPhonePath = choosePath + File.separator + "com.android.dialer" + File.separator + "bbk_dialer_call.png";
        imageView_buttomPhone = getImageView(dialerButtomPhonePath, 361, 132, proportion);
        imageView_buttomPhone.setX(360 / proportion);
        imageView_buttomPhone.setY(1770 / proportion);

        String dialerButtomBGPath = choosePath + File.separator + "com.android.dialer" + File.separator + "bbk_dialer_bottom_bg.png";
        imageView_buttomBackGroud = getImageView(dialerButtomBGPath, 1080, 167, proportion);
        imageView_buttomBackGroud.setX(0);
        imageView_buttomBackGroud.setY(1753 / proportion);

        String dialerButtomBackPath = choosePath + File.separator + "com.android.dialer" + File.separator + "bbk_dialer_del_sel.png";
        imageView_buttomBack = getImageView(dialerButtomBackPath, 128, 128, proportion);
        imageView_buttomBack.setX(835 / proportion);
        imageView_buttomBack.setY(1772 / proportion);
        dialer_buttomPane.getChildren().setAll(imageView_buttomBackGroud, imageView_buttomPeople, imageView_buttomPhone, imageView_buttomBack);
        dialer_buttomHbox.getChildren().setAll(dialer_buttomPane);
        temp_dialerPane.getChildren().setAll(dialerMainBG, topPane, dialer_tipHbox, dialer_keyHbox, dialer_buttomHbox);

        return temp_dialerPane;

    }

    public Pane getMessagePane(String choosePath, int proportion) throws Exception {
        Pane temp_messagePane = new Pane();
        Pane message_tipPane = new Pane();
        Pane message_searchPane = new Pane();
        Pane message_searchTextPane = new Pane();
        Pane messagePane_1 = new Pane();
        Pane messagePane_2 = new Pane();
        Pane messagePane_3 = new Pane();
        Pane messagePane_4 = new Pane();

        ImageView imageView_MainBG = new ImageView();
        ImageView imageView_tipBG = new ImageView();
        ImageView imageView_edit = new ImageView();
        ImageView imageView_searchText = new ImageView();
        ImageView imageView_searchBG = new ImageView();
        ImageView imageView_searchIcon = new ImageView();
        ImageView imageView_messageList_1 = new ImageView();
        ImageView imageView_messageList_2 = new ImageView();
        ImageView imageView_messageList_3 = new ImageView();
        ImageView imageView_messageList_4 = new ImageView();

        HBox message_tipHbox = new HBox();
        HBox message_searchHbox = new HBox();


        //状态栏
        topPane = getTopPane(choosePath, proportion, 0);

        //信息界面的主背景
        String messageMainBGPath = choosePath + File.separator + "com.android.mms" + File.separator + "compose_content_bg.9.png";
        imageView_MainBG = getCanvasImage(messageMainBGPath, 1082, 1922, 1080, 1920, proportion, 1, 0);

        imageView_MainBG.setX(0);
        imageView_MainBG.setY(0);

       /* String messageMainBGPath = choosePath + File.separator + "preview" + File.separator + "preview_contact_1.jpg";
         imageView_MainBG=getImageView(messageMainBGPath,1080,1920,3);*/

        //信息界面的提示栏
        String messageTipPath = choosePath + File.separator + "vivo" + File.separator + "vigour_activity_title_bar_bg_dark.9.png";
        Canvas canvas_tipBG = getNinePatchCanvas(messageTipPath, 1082, 145, 1080, 140, proportion, 1);
        // Canvas canvas_tipBG=getNineCanvas(messageTipPath,1082,140,1080,138,proportion,1);
        imageView_tipBG = getCanvasImage(messageTipPath, 1082, 140, 1080, 140, proportion, 1, 1);
        imageView_tipBG.setX(0);
        imageView_tipBG.setY(70 / proportion);
        canvas_tipBG.setLayoutX(0);
        canvas_tipBG.setLayoutY(65 / proportion);
        //imageView_tipBG.setStyle("-fx-background-color:transparent ");

        ImageView removeTipBlack = removeNineBlack(canvas_tipBG, 1);
        removeTipBlack.setX(0);
        removeTipBlack.setY(70 / proportion);
        removeTipBlack.setFitHeight(140 / proportion);
        removeTipBlack.setFitWidth(1080 / proportion);


        HBox testHbox = new HBox();
        testHbox.getChildren().setAll(removeTipBlack);

        String colorPath = choosePath + File.separator + "com.android.mms" + File.separator + "theme_values.xml";
        String colorValue = getXmlColor(colorPath, "compose_send_text_color");
        String color = changeToRGBA(colorValue);

        Text editText = new Text("编辑");
        // editText.setFont(Font.font(50 / proportion));
        editText.setFont(Font.loadFont("file:res/font/Droid Sans Fallback.ttf", 50 / proportion));
        editText.setFill(Color.web("rgba(" + color + ")"));
        editText.setX(50 / proportion);
        editText.setY(150 / proportion);

        Text messageText1 = new Text();
        messageText1.setText("信息");
        messageText1.setLayoutX(490 / proportion);
        messageText1.setLayoutY(150 / proportion);
        messageText1.setFont(Font.loadFont("file:res/font/Droid Sans Fallback.ttf", 53 / proportion));
        messageText1.setStyle(" -fx-font-weight: BOLD");
        messageText1.setFill(Color.web("rgba(" + color + ")"));


        String messageEdit = choosePath + File.separator + "vivo" + File.separator + "vigour_btn_title_create_center_personal_normal_dark.9.png";
        //  imageView_edit = getCanvasImage(messageEdit, 140, 140, 140, 140, proportion, 1);
        Canvas canvas_edit = getNinePatchCanvas(messageEdit, 140, 140, 140, 140, proportion, 1);
        canvas_edit.setLayoutX(936 / proportion);
        canvas_edit.setLayoutY(70 / proportion);


        message_tipPane.getChildren().addAll(removeTipBlack, editText, messageText1, canvas_edit);
        // message_tipHbox.getChildren().addAll(message_tipPane);

        //搜索栏
        String messageSearchBGPath = choosePath + File.separator + "vivo" + File.separator + "vigour_list_search_bar_bg_light.9.png";
        // imageView_searchBG = getCanvasImage(messageSearchBGPath, 58, 140, 1080, 142, proportion, 1);
        //imageView_searchBG.setX(0);
        //   imageView_searchBG.setY(208 / proportion);
        Canvas searchBG = getNinePatchCanvas(messageSearchBGPath, 58, 140, 1080, 140, proportion, 1);
        searchBG.setLayoutX(0);
        searchBG.setLayoutY(208 / proportion);


        String messageSearchTextPath = choosePath + File.separator + "com.android.mms" + File.separator + "edittext_bg.9.png";
        Canvas canvas_SearchText = getCanvas(messageSearchTextPath, 36, 92, 1030, 92, proportion, 0);

        canvas_SearchText.setLayoutX(28 / proportion);
        canvas_SearchText.setLayoutY(232 / proportion);


        String messageSearchIconPath = choosePath + File.separator + "vivo" + File.separator + "vigour_list_search_icon_dark.png";
        imageView_searchIcon = getImageView(messageSearchIconPath, 90, 90, proportion);
        imageView_searchIcon.setX(45 / proportion);
        imageView_searchIcon.setY(235 / proportion);

        Text searchMessage = new Text("搜索信息");
        // searchMessage.setStyle("-fx-font-weight: bold");
        searchMessage.setFont(Font.font(40 / proportion));
        searchMessage.setFill(Color.GRAY);
        searchMessage.setLayoutX(130 / proportion);
        searchMessage.setLayoutY(295 / proportion);

        message_searchTextPane.getChildren().setAll(canvas_SearchText, imageView_searchIcon, searchMessage);
        message_searchPane.getChildren().setAll(searchBG, message_searchTextPane);
        message_searchHbox.getChildren().setAll(message_searchPane);


        //短信列表
        String messageTelColorPath = choosePath + File.separator + "vivo" + File.separator + "theme_values.xml";
        String messageTelColorValue = getXmlColor(messageTelColorPath, "primary_text_dark_normal");
        String messageTelColor = changeToRGBA(messageTelColorValue);

        String messageContext1ColorPath = choosePath + File.separator + "vivo" + File.separator + "theme_values.xml";
        String messageContext1ColorValue = getXmlColor(messageContext1ColorPath, "secondary_text_normal_light");
        System.out.println("文本里的颜色为值" + messageContext1ColorValue);
        String messageContext1Color = changeToRGBA(messageContext1ColorValue);
        System.out.println("文本里的颜色为" + messageContext1Color);


        Text time_1 = new Text("2017年11月1日");
        time_1.setFont(Font.font(33 / proportion));
        time_1.setFill(Color.web("rgba(" + messageTelColor + ")"));
        time_1.setX(815 / proportion);
        time_1.setY(440 / proportion);

        Text context_1 = new Text("尊敬的联通用户,您好,您当前的优惠信息...");
        context_1.setFont(Font.font(40 / proportion));
        context_1.setFill(Color.web("rgba(" + messageContext1Color + ")"));

        context_1.setX(60 / proportion);
        context_1.setY(483 / proportion);

        Text tel_1 = new Text("10010");

        tel_1.setFont(Font.font(50 / proportion));
        tel_1.setFill(Color.web("rgba(" + messageTelColor + ")"));
        tel_1.setX(60 / proportion);
        tel_1.setY(437 / proportion);


        Text time_2 = new Text("2018年2月13号");
        time_2.setFont(Font.font(33 / proportion));
        time_2.setFill(Color.web("rgba(" + messageTelColor + ")"));
        time_2.setX(815 / proportion);
        time_2.setY(620 / proportion);

        Text context_2 = new Text("温馨提示,至28日10时27分,您的账户当前...");
        context_2.setFont(Font.font(40 / proportion));
        context_2.setFill(Color.web("rgba(" + messageContext1Color + ")"));
        context_2.setX(60 / proportion);
        context_2.setY(663 / proportion);

        Text tel_2 = new Text("10658681");
        tel_2.setFont(Font.font(50 / proportion));
        tel_2.setFill(Color.web("rgba(" + messageTelColor + ")"));
        tel_2.setX(60 / proportion);
        tel_2.setY(606 / proportion);


        Text time_3 = new Text("2018年9月30日");
        time_3.setFont(Font.font(33 / proportion));
        time_3.setFill(Color.web("rgba(" + messageTelColor + ")"));
        time_3.setX(815 / proportion);
        time_3.setY(800 / proportion);

        Text context_3 = new Text("尊敬的用户,您好,您当前可用流量为2MB...");
        context_3.setFont(Font.font(40 / proportion));
        context_3.setFill(Color.web("rgba(" + messageContext1Color + ")"));
        context_3.setX(60 / proportion);
        context_3.setY(840 / proportion);

        Text tel_3 = new Text("10655158");
        tel_3.setFont(Font.font(50 / proportion));
        tel_3.setFill(Color.web("rgba(" + messageTelColor + ")"));
        tel_3.setX(60 / proportion);
        tel_3.setY(790 / proportion);

        int yInit = 520;
        int yValue = 180;

        String messageListPath = choosePath + File.separator + "com.android.mms" + File.separator + "divider.9.png";
        Canvas canvas_MessageList_1 = getNineCanvas(messageListPath, 50, 2, 1080, 4, proportion, 0);
        canvas_MessageList_1.setLayoutX(0);
        canvas_MessageList_1.setLayoutY(yInit / proportion);

        Canvas canvas_MessageList_2 = getNineCanvas(messageListPath, 50, 2, 1080, 4, proportion, 0);
        canvas_MessageList_2.setLayoutX(0);
        canvas_MessageList_2.setLayoutY((yInit + yValue) / proportion);

        Canvas canvas_MessageList_3 = getNineCanvas(messageListPath, 50, 2, 1080, 4, proportion, 0);
        canvas_MessageList_3.setLayoutX(0);
        canvas_MessageList_3.setLayoutY((yInit + yValue * 2) / proportion);

        messagePane_1.getChildren().setAll(canvas_MessageList_1, tel_1, time_1, context_1);
        messagePane_2.getChildren().setAll(canvas_MessageList_2, tel_2, time_2, context_2);
        messagePane_3.getChildren().setAll(canvas_MessageList_3, tel_3, time_3, context_3);

        Pane messageListPane = new Pane();
        messageListPane.getChildren().setAll(messagePane_1, messagePane_2, messagePane_3);

        //temp_messagePane.getChildren().setAll( imageView_tipBG);
        temp_messagePane.getChildren().setAll(imageView_MainBG, topPane, message_tipPane, message_searchHbox, messageListPane);
        return temp_messagePane;
    }

    public Pane getDeskPane(String choosePath, int proportion) throws Exception {


        Pane temp_deskPane = new Pane();
        ImageView imageView_mainBG = new ImageView();

        //状态栏
        topPane = getTopPane(choosePath, proportion, 1);

        //主背景
        String deskMainBGPath = choosePath + File.separator + "wallpaper" + File.separator + "default_wallpaper.png";
        imageView_mainBG = getImageView(deskMainBGPath, 1080, 1920, proportion);

     /*   String deskMainBGPath = choosePath + File.separator + "preview" + File.separator + "preview_launcher_0.jpg";
        imageView_mainBG=getImageView(deskMainBGPath,1080,1920,3);*/


        //时间控件
        ImageView imageView_number_first = new ImageView();
        ImageView imageView_number_second = new ImageView();
        ImageView imageView_tip = new ImageView();
        ImageView imageView_number_third = new ImageView();
        ImageView imageView_number_fourth = new ImageView();

        Pane timePane = new Pane();
        String time_first_Path = choosePath + File.separator + "com.vivo.dream.clock" + File.separator + "number_0.png";
        imageView_number_first = getImageView(time_first_Path, 90, 130, proportion);
        imageView_number_first.setX(60 / proportion);
        imageView_number_first.setY(115 / proportion);

        String time_second_Path = choosePath + File.separator + "com.vivo.dream.clock" + File.separator + "number_5.png";
        imageView_number_second = getImageView(time_second_Path, 90, 130, proportion);
        imageView_number_second.setX(160 / proportion);
        imageView_number_second.setY(115 / proportion);

        String time_tip_Path = choosePath + File.separator + "com.vivo.dream.clock" + File.separator + "number_p.png";
        imageView_tip = getImageView(time_tip_Path, 46, 130, proportion);
        imageView_tip.setX(260 / proportion);
        imageView_tip.setY(115 / proportion);

        String time_third_third = choosePath + File.separator + "com.vivo.dream.clock" + File.separator + "number_2.png";
        imageView_number_third = getImageView(time_third_third, 90, 130, proportion);
        imageView_number_third.setX(300 / proportion);
        imageView_number_third.setY(115 / proportion);

        String time_fourth_fourth = choosePath + File.separator + "com.vivo.dream.clock" + File.separator + "number_0.png";
        imageView_number_fourth = getImageView(time_fourth_fourth, 90, 130, proportion);
        imageView_number_fourth.setX(400 / proportion);
        imageView_number_fourth.setY(115 / proportion);


        //抒写心情
        String colorPath = choosePath + File.separator + "com.vivo.dream.clock" + File.separator + "theme_values.xml";
        String colorValue = getXmlColor(colorPath, "dream_clock_date");
        String color = changeToRGBA(colorValue);

        Text feelText = new Text("抒写心情");
        feelText.setFill(Color.web("rgba(" + color + ")"));
        feelText.setFont(Font.font(80 / proportion));
        feelText.setX(610 / proportion);
        feelText.setY(220 / proportion);

        timePane.getChildren().setAll(imageView_number_first, imageView_number_second, imageView_tip, imageView_number_third, imageView_number_fourth, feelText);

        //日期栏
        Pane dataPane = new Pane();
        ImageView dataBG = new ImageView();
        ImageView editIcon = new ImageView();

        String dataBGPath = choosePath + File.separator + "com.vivo.dream.clock" + File.separator + "data_bg.png";
        dataBG = getImageView(dataBGPath, 995, 72, proportion);
        dataBG.setX(40 / proportion);
        dataBG.setY(250 / proportion);


        String colorPath_data = choosePath + File.separator + "com.vivo.dream.clock" + File.separator + "theme_values.xml";
        String colorValue_data = getXmlColor(colorPath_data, "dream_clock_date");
        String color_data = changeToRGBA(colorValue_data);

        Text dataText = new Text("2018年2月23日");
        dataText.setFill(Color.web("rgba(" + color_data + ")"));
        dataText.setFont(Font.font(35 / proportion));
        dataText.setX(100 / proportion);
        dataText.setY(300 / proportion);

        Text sevenText = new Text("星期五");
        sevenText.setFill(Color.web("rgba(" + color_data + ")"));
        sevenText.setFont(Font.font(35 / proportion));
        sevenText.setX(410 / proportion);
        sevenText.setY(300 / proportion);

        String editIconPath = choosePath + File.separator + "com.vivo.dream.clock" + File.separator + "editor_normal.png";
        editIcon = getImageView(editIconPath, 110, 72, proportion);
        editIcon.setX(925 / proportion);
        editIcon.setY(250 / proportion);

        dataPane.getChildren().setAll(dataBG, dataText, sevenText, editIcon);

        //音乐栏
        Pane musicPane = new Pane();
        ImageView musicBG = new ImageView();

        ImageView love = new ImageView();
        ImageView musicLeft = new ImageView();
        ImageView musicPlay = new ImageView();
        ImageView musicRight = new ImageView();

        String musicBGPath = choosePath + File.separator + "com.vivo.dream.music" + File.separator + "panel_cd.png";
        musicBG = getImageView(musicBGPath, 995, 250, proportion);
        musicBG.setX(40 / proportion);
        musicBG.setY(320 / proportion);

        //混合图片
        String musicHeadPath = choosePath + File.separator + "com.vivo.dream.music" + File.separator + "album_photo_def.png";
        String musicMixPath = choosePath + File.separator + "com.vivo.dream.music" + File.separator + "cd_mix.png";
        ImageView headPhoto = mixPic(musicHeadPath, musicMixPath, 236, 236, proportion);

        headPhoto.setX(110 / proportion);
        headPhoto.setY(320 / proportion);

        String musicLovePath = choosePath + File.separator + "com.vivo.dream.music" + File.separator + "cd_cover.png";
        love = getImageView(musicLovePath, 236, 236, proportion);
        love.setX(110 / proportion);
        love.setY(320 / proportion);

        String colorPath_musicSong = choosePath + File.separator + "com.vivo.dream.music" + File.separator + "theme_values.xml";
        String colorValue__musicSong = getXmlColor(colorPath_musicSong, "dream_music_song_name");
        String color_musicSong = changeToRGBA(colorValue__musicSong);
        Text musicSongName = new Text("歌曲名");
        musicSongName.setFont(Font.loadFont("file:res/font/Droid Sans Fallback.ttf", 40 / proportion));
        musicSongName.setFill(Color.web("rgba(" + color_musicSong + ")"));
        //  musicSongName.setFont(Font.font(40 / proportion));
        musicSongName.setX(350 / proportion);
        musicSongName.setY(370 / proportion);

        String colorPath_musicArtist = choosePath + File.separator + "com.vivo.dream.music" + File.separator + "theme_values.xml";
        String colorValue__musicArtist = getXmlColor(colorPath_musicArtist, "dream_music_artist");
        String color_musicArtist = changeToRGBA(colorValue__musicArtist);

        Text musicSongArtist = new Text("歌手名");
        //  musicSongArtist.setFont(Font.font(null, FontWeight.BOLD, 40 / proportion));
        musicSongArtist.setFont(Font.loadFont("file:res/font/Droid Sans Fallback.ttf", 40 / proportion));
        musicSongArtist.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        //  musicSongArtist.setFont(Font.font(40 / proportion));
        musicSongArtist.setX(700 / proportion);
        musicSongArtist.setY(370 / proportion);

        String musicLeftPath = choosePath + File.separator + "com.vivo.dream.music" + File.separator + "btn_prev_normal.png";
        musicLeft = getImageView(musicLeftPath, 166, 166, proportion);
        musicLeft.setX(400 / proportion);
        musicLeft.setY(400 / proportion);

        String musicPlayPath = choosePath + File.separator + "com.vivo.dream.music" + File.separator + "btn_play_normal.png";
        musicPlay = getImageView(musicPlayPath, 166, 166, proportion);
        musicPlay.setX(600 / proportion);
        musicPlay.setY(400 / proportion);

        String musicRightPath = choosePath + File.separator + "com.vivo.dream.music" + File.separator + "btn_next_normal.png";
        musicRight = getImageView(musicRightPath, 166, 166, proportion);
        musicRight.setX(800 / proportion);
        musicRight.setY(400 / proportion);

        musicPane.getChildren().setAll(musicBG, headPhoto, love, musicSongName, musicSongArtist, musicLeft, musicPlay, musicRight);

        //桌面图标
        Pane deskIconPane = new Pane();
        Pane firstRowPane = new Pane();
        Pane secondPane = new Pane();
        Pane thirdPane = new Pane();
        Pane fourthPane = new Pane();
        Pane lastPane = new Pane();

        ImageView musicIcon = new ImageView();
        ImageView photoIcon = new ImageView();
        ImageView dateIcon = new ImageView();
        ImageView clockIcon = new ImageView();
        ImageView settingIcon = new ImageView();
        ImageView shopIcon = new ImageView();
        ImageView vedioIcon = new ImageView();
        ImageView fileIcon = new ImageView();

        //第一行
        String musicIconPath = choosePath + File.separator + "icons" + File.separator + "com.android.bbkmusic.png";
        musicIcon = getImageView(musicIconPath, 204, 204, proportion);
        musicIcon.setX(60 / proportion);
        musicIcon.setY(1060 / proportion);

        String photoIconPath = choosePath + File.separator + "icons" + File.separator + "com.vivo.gallery.png";
        photoIcon = getImageView(photoIconPath, 204, 204, proportion);
        photoIcon.setX(310 / proportion);
        photoIcon.setY(1060 / proportion);

        String dateIconPath = choosePath + File.separator + "icons" + File.separator + "com.bbk.calendar.png";
        dateIcon = getImageView(dateIconPath, 204, 204, proportion);
        dateIcon.setX(560 / proportion);
        dateIcon.setY(1060 / proportion);

        String clockIconPath = choosePath + File.separator + "icons" + File.separator + "com.android.BBKClock.png";
        clockIcon = getImageView(clockIconPath, 204, 204, proportion);
        clockIcon.setX(810 / proportion);
        clockIcon.setY(1060 / proportion);

        //第二行
        Text musicText = new Text("i 音乐");
        musicText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        musicText.setFont(Font.font(40 / proportion));
        musicText.setX(112 / proportion);
        musicText.setY(1300 / proportion);

        Text photoText = new Text("相册");
        photoText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        photoText.setFont(Font.font(40 / proportion));
        photoText.setX(372 / proportion);
        photoText.setY(1300 / proportion);

        Text dateText = new Text("日历");
        dateText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        dateText.setFont(Font.font(40 / proportion));
        dateText.setX(622 / proportion);
        dateText.setY(1300 / proportion);

        Text clockText = new Text("闹钟时钟");
        clockText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        clockText.setFont(Font.font(40 / proportion));
        clockText.setX(827 / proportion);
        clockText.setY(1300 / proportion);

        //第三行
        String settingIconPath = choosePath + File.separator + "icons" + File.separator + "com.android.settings.png";
        settingIcon = getImageView(settingIconPath, 204, 204, proportion);
        settingIcon.setX(60 / proportion);
        settingIcon.setY(1310 / proportion);

        String shopIconPath = choosePath + File.separator + "icons" + File.separator + "com.bbk.appstore.png";
        shopIcon = getImageView(shopIconPath, 204, 204, proportion);
        shopIcon.setX(310 / proportion);
        shopIcon.setY(1310 / proportion);

        String vedioIconPath = choosePath + File.separator + "icons" + File.separator + "com.android.VideoPlayer.png";
        vedioIcon = getImageView(vedioIconPath, 204, 204, proportion);
        vedioIcon.setX(560 / proportion);
        vedioIcon.setY(1310 / proportion);


        String fileIconPath = choosePath + File.separator + "icons" + File.separator + "com.android.filemanager.png";
        fileIcon = getImageView(fileIconPath, 204, 204, proportion);
        fileIcon.setX(810 / proportion);
        fileIcon.setY(1310 / proportion);

        //第四行
        Text settingText = new Text("设置");
        settingText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        settingText.setFont(Font.font(40 / proportion));
        settingText.setX(125 / proportion);
        settingText.setY(1550 / proportion);

        Text shopText = new Text("应用商店");
        shopText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        shopText.setFont(Font.font(40 / proportion));
        shopText.setX(335 / proportion);
        shopText.setY(1550 / proportion);

        Text vedioText = new Text("视频");
        vedioText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        vedioText.setFont(Font.font(40 / proportion));
        vedioText.setX(622 / proportion);
        vedioText.setY(1550 / proportion);

        Text fileText = new Text("文件管理");
        fileText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        fileText.setFont(Font.font(40 / proportion));
        fileText.setX(827 / proportion);
        fileText.setY(1550 / proportion);

        //第五行
        ImageView telIcon = new ImageView();
        ImageView contactIcon = new ImageView();
        ImageView messageIcon = new ImageView();
        ImageView cameraIcon = new ImageView();

        String telIconPath = choosePath + File.separator + "icons" + File.separator + "com.android.dialer.png";
        telIcon = getImageView(telIconPath, 204, 204, proportion);
        telIcon.setX(60 / proportion);
        telIcon.setY(1650 / proportion);

        String contactIconPath = choosePath + File.separator + "icons" + File.separator + "com.android.contacts.png";
        contactIcon = getImageView(contactIconPath, 204, 204, proportion);
        contactIcon.setX(310 / proportion);
        contactIcon.setY(1650 / proportion);

        String messageIconPath = choosePath + File.separator + "icons" + File.separator + "com.android.mms.png";
        messageIcon = getImageView(messageIconPath, 204, 204, proportion);
        messageIcon.setX(560 / proportion);
        messageIcon.setY(1650 / proportion);

        String cameraIconPath = choosePath + File.separator + "icons" + File.separator + "com.android.camera.png";
        cameraIcon = getImageView(cameraIconPath, 204, 204, proportion);
        cameraIcon.setX(810 / proportion);
        cameraIcon.setY(1650 / proportion);

        //第六行
        Pane sixPane = new Pane();
        Text telText = new Text("电话");
        telText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        telText.setFont(Font.font(40 / proportion));
        telText.setX(125 / proportion);
        telText.setY(1900 / proportion);

        Text contactText = new Text("联系人");
        contactText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        contactText.setFont(Font.font(40 / proportion));
        contactText.setX(353 / proportion);
        contactText.setY(1900 / proportion);

        Text messageText = new Text("信息");
        messageText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        messageText.setFont(Font.font(40 / proportion));
        messageText.setX(622 / proportion);
        messageText.setY(1900 / proportion);

        Text cameraText = new Text("相机");
        cameraText.setFill(Color.web("rgba(" + color_musicArtist + ")"));
        cameraText.setFont(Font.font(40 / proportion));
        cameraText.setX(875 / proportion);
        cameraText.setY(1900 / proportion);

        firstRowPane.getChildren().setAll(musicIcon, photoIcon, dateIcon, clockIcon);
        secondPane.getChildren().setAll(musicText, photoText, dateText, clockText);
        thirdPane.getChildren().setAll(settingIcon, shopIcon, vedioIcon, fileIcon);
        fourthPane.getChildren().setAll(settingText, shopText, vedioText, fileText);
        lastPane.getChildren().setAll(telIcon, contactIcon, messageIcon, cameraIcon);
        sixPane.getChildren().setAll(telText, contactText, messageText, cameraText);

        deskIconPane.getChildren().setAll(firstRowPane, secondPane, thirdPane, fourthPane, lastPane, sixPane);


        temp_deskPane.getChildren().setAll(imageView_mainBG, topPane, timePane, dataPane, musicPane, deskIconPane);

        return temp_deskPane;
    }

    public Pane getTopPane(String choosePath, double proportion, int colorSign) throws Exception {

        String prePath = choosePath.substring(0, choosePath.lastIndexOf("\\"));
        String deskMainBGPath = choosePath + File.separator + "wallpaper" + File.separator + "default_wallpaper.png";

        // System.out.println("目标的上一级目录为" + " " + prePath);

        String colorPath = choosePath + File.separator + "vivo" + File.separator + "theme_values.xml";
        String colorValue = getXmlColor(colorPath, "vivo_window_statusbar_bg_color");
        String color = changeToRGBA(colorValue);
        //设置状态栏背景颜色
        String preUrl_4g = null;
        String preUrl_sign = null;
        String preUrl_time = null;
        String dialerWifiPath = null;
        String dialerBatteryPath = null;

        if (colorSign == 0) {//有状态栏xml
            if ("light".equals(checkedColor(colorValue))) {

                // System.out.println("浅色");
                preUrl_4g = prePath + File.separator + "状态栏资源" + File.separator + "signal_black.png";
                preUrl_sign = prePath + File.separator + "状态栏资源" + File.separator + "vivo_signal4_small_4_color.png";
                preUrl_time = prePath + File.separator + "状态栏资源" + File.separator + "time_black.png";
                dialerWifiPath = prePath + File.separator + "状态栏资源" + File.separator + "wifi_black.png";
                dialerBatteryPath = choosePath + File.separator + "com.android.systemui" + File.separator + "vivo_battery_20_19_color.png";
            } else {
                // System.out.println("深色");
                preUrl_4g = prePath + File.separator + "状态栏资源" + File.separator + "signal_light.png";
                preUrl_sign = prePath + File.separator + "状态栏资源" + File.separator + "vivo_signal4_small_4_white.png";
                preUrl_time = prePath + File.separator + "状态栏资源" + File.separator + "time_light.png";
                dialerWifiPath = prePath + File.separator + "状态栏资源" + File.separator + "wifi_light.png";
                dialerBatteryPath = choosePath + File.separator + "com.android.systemui" + File.separator + "vivo_battery_20_19_white.png";
            }

            topHbox.setBackground(new Background(new BackgroundFill(Color.web("rgba(" + color + ")"), null, null)));
        }


        if (colorSign == 1) {
            String statusBarColor = StatusBarColor(deskMainBGPath, 1080, 70);
            if ("light".equals(statusBarColor)) {

                // System.out.println("浅色");
                preUrl_4g = prePath + File.separator + "状态栏资源" + File.separator + "signal_black.png";
                preUrl_sign = prePath + File.separator + "状态栏资源" + File.separator + "vivo_signal4_small_4_color.png";
                preUrl_time = prePath + File.separator + "状态栏资源" + File.separator + "time_black.png";
                dialerWifiPath = prePath + File.separator + "状态栏资源" + File.separator + "wifi_black.png";
                dialerBatteryPath = choosePath + File.separator + "com.android.systemui" + File.separator + "vivo_battery_20_19_color.png";
            } else {
                // System.out.println("深色");
                preUrl_4g = prePath + File.separator + "状态栏资源" + File.separator + "signal_light.png";
                preUrl_sign = prePath + File.separator + "状态栏资源" + File.separator + "vivo_signal4_small_4_white.png";
                preUrl_time = prePath + File.separator + "状态栏资源" + File.separator + "time_light.png";
                dialerWifiPath = prePath + File.separator + "状态栏资源" + File.separator + "wifi_light.png";
                dialerBatteryPath = choosePath + File.separator + "com.android.systemui" + File.separator + "vivo_battery_20_19_white.png";
            }

        }

        topHbox.setPrefHeight(70 / proportion);
        topHbox.setPrefWidth(1080 / proportion);


        topHbox.getChildren().setAll(topLeftHbox, topCenterHbox, topRightHbox);
        topHbox.setLayoutX(0);
        topHbox.setLayoutY(0);


        imageView_4g = getImageView(preUrl_4g, 39, 32, proportion);
        imageView_4g.setX(27 / proportion);
        imageView_4g.setY(20 / proportion);


        imageView_sign = getImageView(preUrl_sign, 38, 18, proportion);
        imageView_sign.setX(69.5 / proportion);
        imageView_sign.setY(32 / proportion);

        topLeftPane.getChildren().setAll(imageView_4g, imageView_sign);
        topLeftHbox.getChildren().setAll(topLeftPane);


        imageView_time = getImageView(preUrl_time, 101, 30, proportion);
        imageView_time.setX(384 / proportion);
        imageView_time.setY(22 / proportion);
        topCenterPane.getChildren().setAll(imageView_time);
        topCenterHbox.getChildren().setAll(topCenterPane);


        imageView_wifi = getImageView(dialerWifiPath, 39, 31, proportion);
        imageView_wifi.setX(330 / proportion);
        imageView_wifi.setY(20 / proportion);


        imageView_battery = getImageView(dialerBatteryPath, 81, 69, proportion);
        imageView_battery.setX(385 / proportion);
        imageView_battery.setY(2 / proportion);

        topRightPane.getChildren().setAll(imageView_wifi, imageView_battery);
        topRightHbox.getChildren().setAll(topRightPane);

        // topHbox.getChildren().setAll(topLeftHbox, topCenterHbox, topRightHbox);
        Pane temp_topPane = new Pane();
        temp_topPane.getChildren().setAll(topHbox);
        return temp_topPane;


    }


}
